%IFR data for Portugal based on Sorensen et al. (2022), Variation in the COVID-19 infection–fatality ratio by age, time, and geography during the pre-vaccine era:
%a systematic analysis, Lancet 2022; 399: 1469–88, https://doi.org/10.1016/ S0140-6736(21)02867-1
%Table 2, page 1479, Portugal, IFR, April 15, 2020, IFR, July 15, 2020
%IFR, Oct 15, 2020, IFR, Jan 1, 2021

%Raw data from Soerensen et al
ifr_data_raw = timetable(datetime({'2020-03-01';'2020-04-15';'2020-07-15';'2020-10-15';'2021-01-01';'2021-05-15'}), ...
               [NaN;2.683/100;2.085/100;1.805/100;1.708/100;NaN],'VariableNames',{'ifr_data_agg'});
           
%For interpolation to work below, assume ifr in march to be the same as in april.
ifr_data_raw.ifr_data_agg(1) =  ifr_data_raw.ifr_data_agg(2);       
           
%put into weekly format 
ifr_data_weekly = retime(ifr_data_raw,'Weekly','firstvalue');

%interpolate NaNs
ifr_data_weekly=fillmissing(ifr_data_weekly,'previous'); 

%Normalize by July 26, 2020 value of ifr to get time trend
ifr26july2020val=ifr_data_weekly.ifr_data_agg(find(ifr_data_weekly.Time==datetime('26-Jul-2020')));
ifr_data_weekly.trend=ifr_data_weekly.ifr_data_agg/ifr26july2020val;